bloom-filter
A bloom filter suitable for use in Bitcoin Connection Bloom Filtering as part of BIP37.
Get Started
npm install bloom-filter
var BloomFilter = require('bloom-filter');
var numberOfElements = 3;
var falsePositiveRate = 0.01;
var filter = BloomFilter.create(numberofElements, falsePositiveRate);
var a = new Buffer('99108ad8ed9bb6274d3980bab5a85c048f0950c8', 'hex');
var b = new Buffer('19108ad8ed9bb6274d3980bab5a85c048f0950c8', 'hex');
var c = new Buffer('b5a2c786d9ef4658287ced5914b37a1b4aa32eee', 'hex');
filter.insert(a);
filter.insert(b);
assert(!filter.contains(c));
assert(filter.contains(a));
var serialized = filter.toObject();
var filter = new BloomFilter(serialized);
var filter = new BloomFilter({
vData: [],
nHashFucs: 3,
nTweak: 2147483649,
nFlags: 0
});
License
Code released under the MIT license.
Copyright 2015 BitPay, Inc.